<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>消息</title>
    <!--    <link rel="stylesheet" href="../static/css/teachAffair.css">-->
    <link rel="stylesheet" href="https://www.layuicdn.com/layui/css/layui.css">
    <link rel="stylesheet" href="../static/layui/css/layui.css">
    <script src="../static/layui/layui.js"></script>
    <script src="https://www.layuicdn.com/layui/layui.js"></script>
</head>
<body>

<div class="layui-layout layui-layout-admin">
    <!--引入head.html-->
    <div>
        <div class="top" style="margin-bottom: 20px">
            <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">        <ul class="mylayui-nav" style="z-index:1000;">
            <li class="mylayui-nav-item"><a href="/index">首页</a></li>
            <li class="mylayui-nav-item">
                <a id="teachAffairJump" href="#" th:onclick="teachAffairJump([[${role}]])">教务管理</a>
            </li>
            <li class="mylayui-nav-item"><a href="/mod3/index3">舍区管理</a></li>
            <li class="mylayui-nav-item"><a href="/mod3/index4">校园服务</a></li>
            <li class="mylayui-nav-item"><a href="">

                <img th:src="${headPic}" class="mylayui-nav-img" id="headPic">
                <span class="layui-badge-dot" id="dot" th:if="${msgs.size() gt 0}"></span>
            </a>
                <dl class="mylayui-nav-child">
                    <dd>
                        <a href="" id="role" th:text="${role}"></a>
                    </dd>
                    <dd>
                        <a href="/message">
                            消息
                            <span class="layui-badge" id="msgCount"
                                  th:text="${msgs.size()}" th:if="${msgs.size()} gt 0">
                            </span>
                        </a>
                    </dd>
                    <dd>
                        <a href="/logout" th:if="${username} ne ''">
                            注销
                        </a>
                        <a href="/login" th:if="${username} eq ''">
                            登录
                        </a>
                    </dd>
                </dl>
            </li>
        </ul>
        </div>
    </div>
    <!--左侧导航栏-->
    <div class="layui-side layui-bg-black">
        <div class="layui-side-scroll">
            <!-- 左侧导航区域（可配合layui已有的垂直导航） -->
            <ul class="layui-nav layui-nav-tree" lay-filter="nav-tree-test">
                <li class="layui-nav-item layui-nav-itemed">
                    <dd><a href="/messageInfo">未读消息</a></dd>
                </li>
                <li class="layui-nav-item">
                    <dd><a href="/messageInfo1">所有消息</a></dd>
                </li>
            </ul>
        </div>
        <script>
            layui.use('element', function () {
                var $ = layui.jquery, element = layui.element;
                $('dd>a').click(function (e) {
                    if($(this).attr('href') === '/message' || $(this).attr('href') === '/logout') {
                        return;
                    }
                    e.preventDefault();
                    $('#iframeMain').attr('src',$(this).attr('href'));
                });
            })
        </script>
    </div>
    <!--右侧主体-->
    <div class="layui-body">
        <!--用iframe渲染嵌入页面-->
        <div>
            <iframe id="iframeMain" src="/messageInfo" width=100% height=495></iframe>
        </div>
    </div>
</div>

<script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js">

    function teachAffairJump(role) {
        console.log("role: " + role);
        if (role === '教师') {
            $('#teachAffairJump').attr('href', '/teachAffairManagementForTeacher');
        } else if(role === '学生') {
            $('#teachAffairJump').attr('href', '/studentAffairManagement');
        }
    }

</script>

</body>
</html>